package com.aiatomic.couting;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.aiatomic.couting.models.GoodEntity;
import com.aiatomic.couting.util.AppUtils;
import com.aiatomic.couting.util.HttpUtils;
import com.aiatomic.couting.util.SystemUtil;
import com.aiatomic.couting.util.ValidatorUtils;
import com.aiatomic.couting.widgets.LineEditText;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.core.app.ActivityCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.PlatformDb;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.utils.WechatClientNotExistException;

/**
 * A login screen that offers login via email/password.
 * 
 */
public class LoginActivity extends Activity {
	private LineEditText phone;
	private LineEditText txtPassword;
	private static final int RQ_BIND_PHONE = 1000001;
	private final int READ_PHONE_STATE = 100;

	private Handler ev_handler = new Handler();
	private boolean isGranted(String permission) {
		int checkSelfPermission = ActivityCompat.checkSelfPermission(this, permission);
		return checkSelfPermission == PackageManager.PERMISSION_GRANTED;
	}
	private void requestPermission(String permission, int requestCode) {
		if (!isGranted(permission)) {
			ActivityCompat.requestPermissions(this, new String[] { permission }, requestCode);
		} else {
			// 直接执行相应操作了
		}
	}
	/*@Override
	public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
		if (requestCode == READ_PHONE_STATE ) {
			if (grantResults.length>0&&grantResults[0] == PackageManager.PERMISSION_GRANTED) {
			} else {
				finish();
				Toast.makeText(LoginActivity.this, "您没有授权该权限，请在设置中打开授权", Toast.LENGTH_SHORT).show();
			}
			return;
		}
		super.onRequestPermissionsResult(requestCode, permissions, grantResults);
	}*/
	@Override
	protected void onResume() {
		super.onResume();
		if(isGranted(Manifest.permission.READ_PHONE_STATE)){
			autoLogin();
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		//requestPermission(Manifest.permission.READ_PHONE_STATE, READ_PHONE_STATE);
		this.phone = (LineEditText) this.findViewById(R.id.account_et);
		this.txtPassword = (LineEditText) this.findViewById(R.id.password_et);
		initQQ();
		initWeiChat();
		initSinaWebo();
		initEvent();
	}

	private void initEvent() {
		this.findViewById(R.id.forget_pass).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(LoginActivity.this, PasswordForgetActivity.class);
				startActivity(intent);
			}
		});
		this.findViewById(R.id.btn_login).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!ValidatorUtils.isMobileNO(phone.getText().toString())) {
					phone.setError(getResources().getString(R.string.err_input_phone));
					phone.setFocusable(true);
					return;
				}
				if (!ValidatorUtils.isCorrectPassword(txtPassword.getText().toString())) {
					txtPassword.setError(getResources().getString(R.string.err_input_password));
					txtPassword.setFocusable(true);
					return;
				}
				login("", phone.getText().toString(), txtPassword.getText().toString(), "", "", "", "",
						IConstant.CHANNEL_MOB);
			}
		});
		this.findViewById(R.id.btn_register).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
				startActivity(intent);
			}
		});
	}

	public static boolean isWeixinAvilible(Context context) {
		final PackageManager packageManager = context.getPackageManager();// 获取packagemanager
		List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
		if (pinfo != null) {
			for (int i = 0; i < pinfo.size(); i++) {
				String pn = pinfo.get(i).packageName;
				if (pn.equals("com.tencent.mm")) {
					return true;
				}
			}
		}

		return false;
	}

	/**
	 * 判断qq是否可用
	 * 
	 * @param context
	 * @return
	 */
	public static boolean isQQClientAvailable(Context context) {
		final PackageManager packageManager = context.getPackageManager();
		List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
		if (pinfo != null) {
			for (int i = 0; i < pinfo.size(); i++) {
				String pn = pinfo.get(i).packageName;
				if (pn.equals("com.tencent.mobileqq")) {
					return true;
				}
			}
		}
		return false;
	}

	private void initWeiChat() {
		this.findViewById(R.id.iv_wx_login).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!isWeixinAvilible(LoginActivity.this)) {
					Toast toast = Toast.makeText(LoginActivity.this, "没有安装微信客户端", Toast.LENGTH_LONG);
					return;
				}
				Platform platform = ShareSDK.getPlatform(Wechat.NAME);
				// 回调信息，可以在这里获取基本的授权返回的信息，但是注意如果做提示和UI操作要传到主线程handler里去执行
				platform.setPlatformActionListener(new PlatformActionListener() {

					@Override
					public void onError(Platform arg0, int arg1, Throwable arg2) {
						arg2.printStackTrace();
						if (arg2 instanceof WechatClientNotExistException) {
							Toast toast = Toast.makeText(LoginActivity.this, ICodeMsg.ERROR_CODES_QL.get(999),
									Toast.LENGTH_LONG);
							toast.setGravity(Gravity.CENTER, 0, 0);
							toast.show();
						}
					}

					@Override
					public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
						if (action == Platform.ACTION_USER_INFOR) {
							final PlatformDb platDB = platform.getDb();// 获取数平台数据DB
							ev_handler.post(new Runnable() {
								@Override
								public void run() {
									quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
											platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_QQ);
								}
							});
						}
					}

					@Override
					public void onCancel(Platform arg0, int arg1) {

					}
				});
				if (platform.isAuthValid()) {
					PlatformDb platDB = platform.getDb();// 获取数平台数据DB
					quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
							platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_WX);
					return;
				}
				platform.showUser(null);

			}
		});
	}

	private void initSinaWebo() {
		this.findViewById(R.id.iv_blog).setVisibility(View.GONE);
		this.findViewById(R.id.iv_blog).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Platform platform = ShareSDK.getPlatform(SinaWeibo.NAME);
				// 回调信息，可以在这里获取基本的授权返回的信息，但是注意如果做提示和UI操作要传到主线程handler里去执行
				platform.setPlatformActionListener(new PlatformActionListener() {

					@Override
					public void onError(Platform arg0, int arg1, Throwable arg2) {
						arg2.printStackTrace();
					}

					@Override
					public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
						if (action == Platform.ACTION_USER_INFOR) {
							final PlatformDb platDB = platform.getDb();// 获取数平台数据DB
							ev_handler.post(new Runnable() {
								@Override
								public void run() {
									quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
											platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_QQ);
								}
							});
						}
					}

					@Override
					public void onCancel(Platform arg0, int arg1) {

					}
				});

				if (platform.isAuthValid()) {
					PlatformDb platDB = platform.getDb();// 获取数平台数据DB
					quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
							platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_SINA);
					return;
				}
				platform.showUser(null);
			}
		});
	}

	private void initQQ() {
		this.findViewById(R.id.iv_qq_login).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!isQQClientAvailable(LoginActivity.this)) {
					Toast toast = Toast.makeText(LoginActivity.this, "没有安装QQ客户端", Toast.LENGTH_LONG);
					return;
				}
				Platform platform = ShareSDK.getPlatform(QQ.NAME);
				// 回调信息，可以在这里获取基本的授权返回的信息，但是注意如果做提示和UI操作要传到主线程handler里去执行
				platform.setPlatformActionListener(new PlatformActionListener() {

					@Override
					public void onError(Platform arg0, int arg1, Throwable arg2) {
						arg2.printStackTrace();
					}

					@Override
					public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
						if (action == Platform.ACTION_USER_INFOR) {
							final PlatformDb platDB = platform.getDb();// 获取数平台数据DB
							ev_handler.post(new Runnable() {
								@Override
								public void run() {
									quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
											platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_QQ);
								}
							});
						}

					}

					@Override
					public void onCancel(Platform arg0, int arg1) {

					}
				});
				if (platform.isAuthValid()) {
					PlatformDb platDB = platform.getDb();// 获取数平台数据DB
					quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(),
							platDB.getUserName(), platDB.getUserIcon(), IConstant.CHANNEL_QQ);
					return;
				}
				platform.showUser(null);
			}
		});
	}

	private void quick_login_flow(final String openId, final String token, final String nick, final String uName,
			final String uIcon, final int channel) {
		// 检查是否已存在，不存在注册,存在直接登陆
		s_account_v(openId, token, nick, uName, uIcon, channel);

	}

	private void check_server() {
		Map<String, String> params = new HashMap<String, String>();
		params.put("platform", String.valueOf(IConstant.PLATFORM));
		params.put("aid", AppUtils.aid);
		params.put("client_version", SystemUtil.getAppVersion(this));
		params.put("time", String.valueOf(Calendar.getInstance().getTimeInMillis()));
		params.put("channel", String.valueOf(AppUtils.channel));
		params.put("sign", HttpUtils.md5(params.get("aid") + params.get("time") + params.get("client_version")
				+ params.get("platform") + params.get("channel") + IConstant.NORMAL_MD5_KEY));
		params.put("ssign", HttpUtils.md5(params.get("aid") + params.get("time") + params.get("client_version")
				+ params.get("platform") + params.get("channel") + AppUtils.sKey));
		HttpUtils.post(new Handler() {

			@Override
			public void handleMessage(Message msg) {
				if (msg.what == HttpUtils.CODE_SUCCESS_RQ_100) {
					try {
						JSONObject json = new JSONObject(msg.obj.toString());
						if (json.getInt("code") == HttpUtils.RET_SUCCESS) {
							JSONArray goods = json.getJSONArray("goods");
							for (int i = 0; i < goods.length(); i++) {
								JSONObject good = goods.getJSONObject(i);
								GoodEntity entity = new GoodEntity();
								entity.setSb_good_id(good.getString("sb_good_id"));
								entity.setDesc(good.getString("desc"));
								entity.setDiscount(good.getDouble("discount"));
								entity.setFirst_give(good.getInt("first_give"));
								entity.setGive_days(good.getInt("give_days"));
								entity.setIs_test(good.getInt("is_test") == 0 ? false : true);
								entity.setName(good.getString("name"));
								entity.setPic(good.getInt("pic"));
								entity.setPlatform(good.getInt("platform"));
								entity.setPos(good.getInt("pos"));
								entity.setPrice(good.getDouble("price"));
								entity.setType(good.getInt("type"));
								AppUtils.goods.add(entity);
							}
							AppUtils.currency_day = json.getJSONObject("currency").getInt("days");
							AppUtils.order_clean=json.getInt("order_clean");
							Intent intent = new Intent(LoginActivity.this, MainActivity.class);
							startActivity(intent);
						} else {
							Toast toast = Toast.makeText(LoginActivity.this, json.getString("msg"), Toast.LENGTH_LONG);
							toast.setGravity(Gravity.CENTER, 0, 0);
							toast.show();
						}
					} catch (JSONException e) {
						e.printStackTrace();
						Log.e("", msg.obj.toString());
						Toast toast = Toast.makeText(LoginActivity.this,
								LoginActivity.this.getResources().getString(R.string.server_format_error),
								Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
					}
				} else {
					Toast toast = Toast.makeText(LoginActivity.this, ICodeMsg.ERROR_CODES_HTTP.get(msg.what),
							Toast.LENGTH_LONG);
					toast.setGravity(Gravity.CENTER, 0, 0);
					toast.show();
				}
			}

		}, AppUtils.url + "/v/cindex/check_server/", params);
	}

	
	private void s_reg(final String openId, final String token, final String nick, final String uName,
			final String uIcon, final int channel, String mobile) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("imei", SystemUtil.getIMEI(LoginActivity.this));
		params.put("device",
				SystemUtil.getDeviceBrand() + ";" + SystemUtil.getSystemModel() + ";" + SystemUtil.getSystemVersion());
		params.put("mobile", mobile);
		params.put("openId", openId);
		params.put("token", token);
		params.put("nick", nick);
		params.put("uName", uName);
		params.put("uIcon", uIcon);
		params.put("platform", String.valueOf(IConstant.PLATFORM));
		params.put("channel", String.valueOf(channel));
		params.put("sign",
				HttpUtils.md5(params.get("imei") + params.get("device") + params.get("openId") + params.get("token")
						+ params.get("nick") + params.get("uName") + params.get("uIcon") + params.get("platform")
						+ params.get("channel") + IConstant.NORMAL_MD5_KEY));
		HttpUtils.post(new Handler() {

			@Override
			public void handleMessage(Message msg) {
				if (msg.what == HttpUtils.CODE_SUCCESS_RQ_100) {
					try {
						JSONObject json = new JSONObject(msg.obj.toString());
						Toast toast = Toast.makeText(LoginActivity.this, json.getString("msg"), Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
						if (json.getInt("code") == HttpUtils.RET_SUCCESS) {
							login(openId, "", "", token, nick, uName, uIcon, channel);
						}
					} catch (JSONException e) {
						e.printStackTrace();
						Log.e("", msg.obj.toString());
						Toast toast = Toast.makeText(LoginActivity.this,
								LoginActivity.this.getResources().getString(R.string.server_format_error),
								Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
					}
				} else if (msg.what == HttpUtils.CODE_ERROR_RQ_999) {
					Toast toast = Toast.makeText(LoginActivity.this, ICodeMsg.ERROR_CODES_HTTP.get(msg.what),
							Toast.LENGTH_LONG);
					toast.setGravity(Gravity.CENTER, 0, 0);
					toast.show();
				}
			}

		}, IConstant.CENTER + "/v/Account_c/account_q_create/", params);
	}
	private void login(final String openId, final String mobile, final String pwd, final String token,
			final String nick, final String uName, final String uIcon, final int channel) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("pwd", pwd);
		params.put("openId", openId);
		params.put("mobile", mobile);
		params.put("token", token);
		params.put("nick", nick);
		params.put("uName", uName);
		params.put("uIcon", uIcon);
		params.put("imei", SystemUtil.getIMEI(LoginActivity.this));
		params.put("platform", String.valueOf(IConstant.PLATFORM));
		params.put("channel", String.valueOf(channel));
		params.put("sign", HttpUtils.md5(openId + mobile + pwd + token + nick + uName + uIcon + params.get("platform")
				+ params.get("channel") + IConstant.NORMAL_MD5_KEY));
		HttpUtils.post(new Handler() {

			@Override
			public void handleMessage(Message msg) {
				if (msg.what == HttpUtils.CODE_SUCCESS_RQ_100) {
					try {
						JSONObject json = new JSONObject(msg.obj.toString());
						Toast toast = Toast.makeText(LoginActivity.this, json.getString("msg"), Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
						if (json.getInt("code") == HttpUtils.RET_SUCCESS) {
							AppUtils.clean();
							AppUtils.sid = json.getInt("sid");
							AppUtils.sname = json.getString("sname");
							AppUtils.nick = json.getString("nick");
							AppUtils.url = json.getString("url");
							AppUtils.sUrl = json.getString("https_url");
							AppUtils.sKey = json.getString("s_key");
							AppUtils.channel = json.getInt("channel");
							AppUtils.aid = json.getString("aid");
							AppUtils.mob = json.getString("mobile");
							saveLoginState(openId, mobile, pwd, token, nick, uName, uIcon, channel);
							check_server();
						}
					} catch (JSONException e) {
						e.printStackTrace();
						Log.e("", msg.obj.toString());
						Toast toast = Toast.makeText(LoginActivity.this,
								LoginActivity.this.getResources().getString(R.string.server_format_error),
								Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
					}
				} else {
					Toast toast = Toast.makeText(LoginActivity.this, ICodeMsg.ERROR_CODES_HTTP.get(msg.what),
							Toast.LENGTH_LONG);
					toast.setGravity(Gravity.CENTER, 0, 0);
					toast.show();
				}
			}

		}, IConstant.CENTER + "/v/Account_c/account_login/", params);
	}

	class Account_v_handler extends Handler {
		private String openId;
		private String mobile;
		private String pwd;
		private String token;
		private String nick;
		private String uName;
		private String uIcon;
		private int channel;

		public Account_v_handler(String openId, String mobile, String pwd, String token, String nick, String uName,
				String uIcon, int channel) {
			super();
			this.openId = openId;
			this.mobile = mobile;
			this.pwd = pwd;
			this.token = token;
			this.nick = nick;
			this.uName = uName;
			this.uIcon = uIcon;
			this.channel = channel;
		}

		@Override
		public void handleMessage(Message msg) {
			if (msg.what == HttpUtils.CODE_SUCCESS_RQ_100) {
				try {
					JSONObject json = new JSONObject(msg.obj.toString());
					if (json.getInt("code") == HttpUtils.RET_SUCCESS) {

						login(openId, "", "", token, nick, uName, uIcon, channel);
					} else if (json.getInt("code") == HttpUtils.RET_ERR_ACCOUNT_NON_EXIST) {
						s_reg(openId,token,nick,uName,uIcon,channel,"");

						/*Intent intent = new Intent(LoginActivity.this, BindPhoneActivity.class);
						intent.putExtra("openId", openId);
						intent.putExtra("token", token);
						intent.putExtra("nick", nick);
						intent.putExtra("uName", uName);
						intent.putExtra("uIcon", uIcon);
						intent.putExtra("channel", channel);
						LoginActivity.this.startActivityForResult(intent, RQ_BIND_PHONE);*/
					} else {
						Toast toast = Toast.makeText(LoginActivity.this, json.getString("msg"), Toast.LENGTH_LONG);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();
					}
				} catch (JSONException e) {
					e.printStackTrace();
					Log.e("", msg.obj.toString());
					Toast toast = Toast.makeText(LoginActivity.this,
							LoginActivity.this.getResources().getString(R.string.server_format_error),
							Toast.LENGTH_LONG);
					toast.setGravity(Gravity.CENTER, 0, 0);
					toast.show();
				}
			} else {
				Toast toast = Toast.makeText(LoginActivity.this, ICodeMsg.ERROR_CODES_HTTP.get(msg.what),
						Toast.LENGTH_LONG);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show();
			}
		}

	};

	private Account_v_handler s_account_v_handler;

	/**
	 * 校验是否存在
	 * 
	 * @param openId
	 * @param token
	 * @param nick
	 * @param uName
	 */
	private void s_account_v(final String openId, final String token, final String nick, final String uName,
			final String uIcon, final int channel) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("openId", openId);
		params.put("platform", String.valueOf(IConstant.PLATFORM));
		params.put("channel", String.valueOf(channel));
		params.put("sign", HttpUtils
				.md5(params.get("openId") + params.get("platform") + params.get("channel") + IConstant.NORMAL_MD5_KEY));
		if (s_account_v_handler != null) {
			s_account_v_handler = null;
		}
		s_account_v_handler = new Account_v_handler(openId, "", "", token, nick, uName, uIcon, channel);
		HttpUtils.post(s_account_v_handler, IConstant.CENTER + "/v/Account_c/account_v/", params);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		if (requestCode == RQ_BIND_PHONE && resultCode == HttpUtils.RET_SUCCESS) {
			// 自动登陆
			String openId = intent.getStringExtra("openId");
			String token = intent.getStringExtra("token");
			String nick = intent.getStringExtra("nick");
			String uName = intent.getStringExtra("uName");
			String uIcon = intent.getStringExtra("uIcon");
			int channel = intent.getIntExtra("channel", 0);
			login(openId, "", "", token, nick, uName, uIcon, channel);
			return;
		}
	}

	private void saveLoginState(final String openId, final String mobile, final String pwd, final String token,
			final String nick, final String uName, final String uIcon, final int channel) {
		SharedPreferences sharedPreferences = getSharedPreferences("safe_login", this.MODE_PRIVATE);
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putString("openId", openId);
		editor.putString("mobile", mobile);
		editor.putString("pwd", pwd);
		editor.putString("token", token);
		editor.putString("nick", nick);
		editor.putString("uName", uName);
		editor.putString("uIcon", uIcon);
		editor.putInt("channel", channel);
		editor.commit();
	}

	private void autoLogin() {
		SharedPreferences sharedPreferences = getSharedPreferences("safe_login", this.MODE_PRIVATE);
		int channel = sharedPreferences.getInt("channel", -1);
		switch (channel) {
		case IConstant.CHANNEL_MOB: {
			String phone = sharedPreferences.getString("mobile", "");
			String pwd = sharedPreferences.getString("pwd", "");
			if (phone.equals("") || pwd.equals("")) {
				return;
			}
			login("", phone, pwd, "", "", "", "", IConstant.CHANNEL_MOB);
			break;
		}
		case IConstant.CHANNEL_QQ: {
			Platform platform = ShareSDK.getPlatform(QQ.NAME);
			if (platform.isAuthValid()) {
				PlatformDb platDB = platform.getDb();// 获取数平台数据DB
				quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(), platDB.getUserName(),
						platDB.getUserIcon(), IConstant.CHANNEL_QQ);
				return;
			}
			break;
		}
		case IConstant.CHANNEL_WX: {
			Platform platform = ShareSDK.getPlatform(Wechat.NAME);
			if (platform.isAuthValid()) {
				PlatformDb platDB = platform.getDb();// 获取数平台数据DB
				quick_login_flow(platDB.getUserId(), platDB.getToken(), platDB.getUserGender(), platDB.getUserName(),
						platDB.getUserIcon(), IConstant.CHANNEL_SINA);
				return;
			}
			break;
		}
		}

	}

}
